import 'package:flutter/material.dart';
import 'package:flutter_deer/shop/models/user_entity.dart';
import 'package:flutter_deer/util/other_utils.dart';
import 'package:flutter_deer/widgets/state_layout.dart';

class UserProvider extends ChangeNotifier {

  bool? _agentUser = false;
  bool? get agentUser => _agentUser;
  UserInfoEntity? _user;
  UserInfoEntity? get user => _user;
  StateType? _stateType = StateType.loading;
  StateType? get stateType => _stateType;
  String? get nickname => _user!.sysUser!.nickname!.nullSafe;
  
  void setUser(UserInfoEntity? user) {
    this._user = user;
    this._stateType = StateType.empty;
    notifyListeners();
  }

  void setAgentUser(bool? flag) {
    this._agentUser = flag;
    notifyListeners();
  }

  void setUserAvatar(String? avatar){
    _user!.sysUser!.avatar = avatar;
    notifyListeners();
  }
}
